package com.my.selectcoursesystem.service.serviceImpl;

import com.my.selectcoursesystem.bean.Teacher;
import com.my.selectcoursesystem.dao.TeacherDao;
import com.my.selectcoursesystem.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("TeacherService")
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherDao teacherDao;

    public TeacherServiceImpl(TeacherDao teacherDao) {
        this.teacherDao = teacherDao;
    }

    public TeacherServiceImpl() {
    }

    @Override
    public Teacher getTeacherById(String t_id) {
        return this.teacherDao.findByTid(t_id);
    }

    @Override
    public Teacher getTeacher(String t_code, String t_password) {
        return this.teacherDao.findByTcodeAndTpassword(t_code, t_password);
    }

    @Override
    public Boolean modifyTeacherPass(Teacher teacher) {
        try {
            this.teacherDao.save(teacher);
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
}
